-
Notifications
You must be signed in to change notification settings - Fork 8
Slay the dragon #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slay the dragon #57
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #57 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 10 10
Lines 296 296
=========================================
Hits 296 296 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| (l::law)(wavelength::U.Quantity) = l(U.ustrip(U.u"Å", wavelength)) * U.u"mag" | ||
| end | ||
| # generate unitful support | ||
| (l::ExtinctionLaw)(wavelength::U.Quantity) = l(U.ustrip(U.u"Å", wavelength)) * U.u"mag" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we're editing this I wonder if it makes sense to check dimensions here by dispatching as (l::ExtinctionLaw)(wavelength::U.Length) because wavelengths only make sense as lengths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Making the switch seems to make the error message a bit more opaque though:
With (l::ExtinctionLaw)(wavelength::U.Quantity)
julia> CCM89()(1e4/5)
2.8425264357868345
julia> CCM89()(2000u"Å")
2.8425264357868345 mag
julia> CCM89()(2000u"kg")
ERROR: DimensionError: Å and kg are not dimensionally compatible.
Stacktrace:
[1] #s103#141
@ ~/.julia/packages/Unitful/nwwOk/src/conversion.jl:28 [inlined]
[2] var"#s103#141"(::Any, s::Any, t::Any)
@ Unitful ./none:0
[3] (::Core.GeneratedFunctionStub)(::UInt64, ::LineNumberNode, ::Any, ::Vararg{Any})
@ Core ./boot.jl:707
[4] uconvert(a::Unitful.FreeUnits{(Å,), 𝐋, nothing}, x::Quantity{Int64, 𝐌, Unitful.FreeUnits{(kg,), 𝐌, nothing}})
@ Unitful ~/.julia/packages/Unitful/nwwOk/src/conversion.jl:93
[5] ustrip
@ ~/.julia/packages/Unitful/nwwOk/src/utils.jl:37 [inlined]
[6] (::CCM89)(wavelength::Quantity{Int64, 𝐌, Unitful.FreeUnits{(kg,), 𝐌, nothing}})
@ DustExtinction ~/projects/DustExtinction.jl/src/DustExtinction.jl:167
[7] top-level scope
@ REPL[30]:1With (l::ExtinctionLaw)(wavelength::U.Length)
julia> CCM89()(1e4/5)
2.8425264357868345
julia> CCM89()(2000u"Å")
2.8425264357868345 mag
julia> CCM89()(2000u"kg")
ERROR: MethodError: no method matching (::CCM89)(::Quantity{Int64, 𝐌, Unitful.FreeUnits{(kg,), 𝐌, nothing}})
The object of type `CCM89` exists, but no method is defined for this combination of argument types when trying to treat it as a callable object.
Closest candidates are:
(::CCM89)(::T) where T<:Real
@ DustExtinction ~/projects/DustExtinction.jl/src/color_laws/ccm89.jl:25
(::DustExtinction.ExtinctionLaw)(::Union{Quantity{T, 𝐋, U}, Level{L, S, Quantity{T, 𝐋, U}} where {L, S}} where {T, U})
@ DustExtinction ~/projects/DustExtinction.jl/src/DustExtinction.jl:167
Stacktrace:
[1] top-level scope
@ REPL[25]:1There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I guess the type conversion ends up requiring a length anyway, nbd
|
Looks good to merge |
Now that we are past supporting pre-v1.3 versions of Julia, are we ready to put this legendary comment to rest?